package utils;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.mail.MessagingException;

/**
 * Created by sealer on 17/05/03.
 */
public class LogUtil {
    private Logger logger;
    private LogUtil(Class<?> clazz) {
        logger = LoggerFactory.getLogger(clazz);
    }

    public static LogUtil getInstance(Class<?> clazz) {
        return new LogUtil(clazz);
    }

    public void debug(String msg) {
        logger.debug(msg);
    }

    public void info(String msg) {
        logger.info(msg);
    }

    public void warn(String msg) {
        logger.warn(msg);
    }

    public void error(String msg) {
        logger.error(msg);
        String[] recipients = new String[] {"mysealer@163.com", "1178884049@qq.com", "azuresky52923@gmail.com", "liangshile@csii.com.cn"};
        try {
            MailSender.getInstance().send(recipients, logger.getName() + "Error", msg);
        } catch (MessagingException e) {
            e.printStackTrace();
        }
    }


}
